package com.maybach.common.enums;

/**
 * Created by songshuang on 16/3/2.
 */
public enum CarStandardEnum {
    /**
     * 国产
     */
    MadeInChina("国产", 0),
    /**
     * 中规  1
     */
    China("中规", 1),
    /**
     * 美规  2
     */
    America("美规", 2),
    /**
     * 加规  3
     */
    Canada("加规", 3),
    /**
     * 中东  4
     */
    East("中东", 4),
    /**
     * 欧规  5
     */
    Europe("欧规", 5),

    /**
     * 墨西哥版  6
     */
    Mexico("墨西哥版", 6),

    /**
     * 中规车, 包括 MadeInChina + China
     */
    AllChina("中规", 100);

    private String desc;

    private Integer status;

    CarStandardEnum(String desc, Integer status) {
        this.desc = desc;
        this.status = status;
    }

    public String getDesc() {
        return desc;
    }

    public Integer getStatus() {
        return status;
    }

    public static boolean isChina(Integer value) {
        return MadeInChina.getStatus().equals(value) || China.getStatus().equals(value);
    }

    public static CarStandardEnum valueOf(Integer value) {
        switch (value) {
            case 0:
                return MadeInChina;
            case 1:
                return China;
            case 2:
                return America;
            case 3:
                return Canada;
            case 4:
                return East;
            case 5:
                return Europe;
            case 6:
                return Mexico;
            default:
                return America;
        }
    }

    public static CarStandardEnum getStandard(String desc) {
        if (MadeInChina.desc.equals(desc)){
            return MadeInChina;
        }else if (China.desc.equals(desc)){
            return China;
        }else if (America.desc.equals(desc)){
            return America;
        }else if (Canada.desc.equals(desc)){
            return Canada;
        }else if (East.desc.equals(desc)){
            return East;
        }else if (Europe.desc.equals(desc)){
            return Europe;
        }else if (Mexico.desc.equals(desc)){
            return Mexico;
        }
        return null;
    }

    public int value() {
        return this.status;
    }
}
